package com.bit.ioc.controller;

import com.bit.ioc.config.UserConfig;
import com.bit.ioc.model.UserInfo;
import com.bit.ioc.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;

@Controller
public class UserController {

    /**
     * 属性注入
     */
//    @Autowired
//    private UserService us;
//    @Autowired
//    private UserConfig userConfig;


    /**
     * 构造方法注入
     */

//    private UserService userService;
//    private UserConfig userConfig;
//
////    public UserController() {
////    }
//
//    public UserController(UserService userService) {
//        this.userService = userService;
//    }
//    @Autowired
//    public UserController(UserService userService, UserConfig userConfig) {
//        this.userService = userService;
//        this.userConfig = userConfig;
//
//    }

    /**
     * Setter方法注入
     */
//
//    private UserService userService;
//    private UserConfig userConfig;
//
//    @Autowired
//    public void setUserService(UserService userService) {
//        this.userService = userService;
//    }
//
//    @Autowired
//    public void setUserConfig(UserConfig userConfig) {
//        this.userConfig = userConfig;
//    }

    @Qualifier("userInfo2")
    @Autowired
    private UserInfo userInfo1;


//    @Resource(name = "userInfo1")
//    private UserInfo userInfo;

    public void  hello(){
        System.out.println("hello, UserController...");
//        us.hello();
//        userConfig.hello();
        System.out.println(userInfo1);
    }
}
